#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const ll INF=1e18;
const int M=998244353;
const int N=1e3+100;
vector<set<int>>adj;
set<int>prs;
vector<int>par;
int n;
int inv(int i){
return i <= 1 ? i : M - (long long)(M/i) * inv(M % i) % M;
}
int binpow(int a,int p){
int ans=1;
while(p>0){
if(p%2){
ans=(ans*a);
}
a=(a*a);
p/=2;
}
return ans;
}
void dfs(int s,vector<int>&d,vector<int>&v){
v[s]=1;
for(auto it:adj[s]){
if(v[it]==0&&prs.find(it)!=prs.end()){
d[it]=d[s]+1;
par[it]=s;
dfs(it,d,v);
}
}
}
vector<int>diameter(int s){
vector<int>vis,dis;
dis.assign(n,INF);
vis.assign(n,0);
dis[s]=0;
dfs(s,dis,vis);
int ma=s;
int c=0;
for(int i=0;i<n;i++){
if(dis[i]==INF)continue;
if(dis[ma]<dis[i])ma=i;
c++;
//cout<<i+1<<" ";
}
dis.assign(n,INF);
vis.assign(n,0);
dis[ma]=0;par[ma]=ma;
dfs(ma,dis,vis);
int ma2=s;
for(int i=0;i<n;i++){
if(dis[i]==INF)continue;
if(dis[ma2]<dis[i])ma2=i;
}
vector<int>ans={dis[ma2],ma,ma2,c};
return ans;
}
int32_t main(){
IOS
int t=1;
//cin>>t;
while(t--){
cin>>n;
adj.assign(n,{});
par.assign(n,-1);
prs.insert(n-1);
for(int i=0;i<n-1;i++){
prs.insert(i);
int a,b;
cin>>a>>b;
a--;b--;
adj[b].insert(a);
adj[a].insert(b);
}
int cur=n;
int pnode=0;
int lca=0;
if(n==2){
cout<<"? "<<1<<" "<<2<<endl;
cin>>lca;
cout<<"! "<<lca<<endl;
continue;
}
vector<int>d=diameter(pnode);
int c=0;
while(prs.size()>3){
if(c==(n/2)){
cout<<-1<<endl;
return 0;
}
cout<<"? "<<d[1]+1<<" "<<d[2]+1<<endl;
c++;
cin>>lca;
lca--;
pnode=lca;
if(lca==d[1]||lca==d[2]){
cout<<"! "<<lca+1<<endl;
return 0;
}
prs.erase(d[1]);
prs.erase(d[2]);
d=diameter(lca);
}
cout<<"! "<<lca+1<<endl;
cout.flush();
}
return 0;
}
1327B - Princesses and Princes | 1450F - The Struggling Contestant |
1399B - Gifts Fixing | 1138A - Sushi for Two |
982C - Cut 'em all | 931A - Friends Meeting |
1594A - Consecutive Sum Riddle | 1466A - Bovine Dilemma |
454A - Little Pony and Crystal Mine | 2A - Winner |
1622B - Berland Music | 1139B - Chocolates |
1371A - Magical Sticks | 1253A - Single Push |
706B - Interesting drink | 1265A - Beautiful String |
214A - System of Equations | 287A - IQ Test |
1108A - Two distinct points | 1064A - Make a triangle |
1245C - Constanze's Machine | 1005A - Tanya and Stairways |
1663F - In Every Generation | 1108B - Divisors of Two Integers |
1175A - From Hero to Zero | 1141A - Game 23 |
1401B - Ternary Sequence | 598A - Tricky Sum |
519A - A and B and Chess | 725B - Food on the Plane |